/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * com_distri_provee_comp_vs_ven.java
 *
 * Created on 12/05/2011, 09:10:43 AM
 */

package sie_invdis;


import java.sql.*;
import javax.swing.*;

import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.JTable.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.print.PrinterException;
import java.util.Date;
import java.util.Calendar;
import java.text.SimpleDateFormat;
import java.text.ParseException;
import java.text.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;

import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.ui.RefineryUtilities;

import javax.swing.table.DefaultTableCellRenderer;

/**
 *
 * @author Michelle
 */
public class com_distri_provee_comp_vs_ven extends javax.swing.JFrame {


    private javax.swing.table.DefaultTableModel jtable_modelo;
 
    private javax.swing.table.DefaultTableModel jtable_modelo_articyestadis;
    private javax.swing.table.DefaultTableModel jtable_modelo_ventasxmes;
    private javax.swing.table.DefaultTableModel jtable_modelo_periodo;
    private javax.swing.table.DefaultTableModel jtable_modelo_periodode;
     private javax.swing.table.DefaultTableModel jtable_modelo_estadisticas;

    bd_conexion x = new bd_conexion();
    ResultSet rs = null;
    private int opcioncons=4;
     private java.util.Date fechahoy=new Date();
    DefaultTableCellRenderer alinearCentro, alinearderecha, alinearIzquierda;
private float totalcostogral=0,totalcostovendido=0,indexactual=0,yacargue0=0,yacargue1=0,yacargue2=0,band=0;;
    private SimpleDateFormat formateadoresta = new SimpleDateFormat("yyyy-MM-dd");
    String opvs="1";

    /** Creates new form com_distri_provee_comp_vs_ven */
    public com_distri_provee_comp_vs_ven() {
        this.iniciar_modelo_de_tabla();
        this.iniciar_modelo_ventasxmes();
        this.iniciar_modelo_artiyesta();
        this.iniciar_modelo_periodos();
        this.iniciar_modelo_periodosde();
        this.iniciar_modelo_articuloestadistica();
        initComponents();

        this.buttonGroup1.setSelected(jrbn_repguar.getModel(), true);
        this.buttonGroup2.setSelected(jrbn_vscompras.getModel(), true);

        
        jtb_provee_comvsventas.getColumnModel().getColumn(0).setPreferredWidth(60);//tem ent
        jtb_provee_comvsventas.getColumnModel().getColumn(1).setPreferredWidth(120);//familia
        jtb_provee_comvsventas.getColumnModel().getColumn(2).setPreferredWidth(60);//subfam.
        jtb_provee_comvsventas.getColumnModel().getColumn(3).setPreferredWidth(70);//id
        jtb_provee_comvsventas.getColumnModel().getColumn(4).setPreferredWidth(70);//clave
        jtb_provee_comvsventas.getColumnModel().getColumn(5).setPreferredWidth(70);//descrip.
        jtb_provee_comvsventas.getColumnModel().getColumn(6).setPreferredWidth(70);//item
        jtb_provee_comvsventas.getColumnModel().getColumn(7).setPreferredWidth(70);//precio
        jtb_provee_comvsventas.getColumnModel().getColumn(8).setPreferredWidth(70);//f.ult. compra
        jtb_provee_comvsventas.getColumnModel().getColumn(9).setPreferredWidth(70);//f.ult. compra

      

        jt_articulosestadisticas.getColumnModel().getColumn(0).setPreferredWidth(60);//tem ent
       jt_articulosestadisticas.getColumnModel().getColumn(1).setPreferredWidth(80);//familia
       jt_articulosestadisticas.getColumnModel().getColumn(2).setPreferredWidth(120);//subfam.
        jt_articulosestadisticas.getColumnModel().getColumn(3).setPreferredWidth(10);//id
       jt_articulosestadisticas.getColumnModel().getColumn(4).setPreferredWidth(10);//clave
        jt_articulosestadisticas.getColumnModel().getColumn(5).setPreferredWidth(40);//descrip.
        jt_articulosestadisticas.getColumnModel().getColumn(6).setPreferredWidth(5);//item
       jt_articulosestadisticas.getColumnModel().getColumn(7).setPreferredWidth(5);//precio
        jt_articulosestadisticas.getColumnModel().getColumn(8).setPreferredWidth(5);//f.ult. compra
       
       jtb_provee_comvsventas3.getColumnModel().getColumn(0).setPreferredWidth(80);//tem ent
       jtb_provee_comvsventas3.getColumnModel().getColumn(1).setPreferredWidth(10);//familia

        jtb_provee_comvsventas.getTableHeader().setBackground(Color.yellow);
        
        //jtb_provee_comvsventas.getTableHeader().setPreferredSize(new Dimension(jtb_provee_comvsventas.getTableHeader().getWidth(),60));

        if(JOptionPane.showConfirmDialog(null, "Desea Cargar Datos?")==0)
                {
                    this.cargar_datosarticulosexisyacum(4,"0","1");
                }
        
        this.loadcomboclasif();
        band=1;
    }
public void centrar_datos()
    {
        alinearderecha = new DefaultTableCellRenderer();
        alinearderecha.setHorizontalAlignment(SwingConstants.RIGHT);

        alinearCentro = new DefaultTableCellRenderer();
        alinearCentro.setHorizontalAlignment(SwingConstants.CENTER);

        jtb_provee_comvsventas.getColumnModel().getColumn(3).setCellRenderer(alinearderecha);
        jtb_provee_comvsventas.getColumnModel().getColumn(4).setCellRenderer(alinearderecha);
        jtb_provee_comvsventas.getColumnModel().getColumn(5).setCellRenderer(alinearderecha);
        jtb_provee_comvsventas.getColumnModel().getColumn(6).setCellRenderer(alinearderecha);
        jtb_provee_comvsventas.getColumnModel().getColumn(7).setCellRenderer(alinearderecha);
        jtb_provee_comvsventas.getColumnModel().getColumn(8).setCellRenderer(alinearderecha);

        jtb_provee_comvsventas.getColumnModel().getColumn(9).setCellRenderer(alinearCentro);

        jt_vengenxmes.getColumnModel().getColumn(1).setCellRenderer(alinearderecha);
        jt_vengenxmes.getColumnModel().getColumn(2).setCellRenderer(alinearderecha);
       jt_vengenxmes.getColumnModel().getColumn(3).setCellRenderer(alinearderecha);
        jt_vengenxmes.getColumnModel().getColumn(4).setCellRenderer(alinearderecha);
        jt_vengenxmes.getColumnModel().getColumn(5).setCellRenderer(alinearderecha);
        jt_vengenxmes.getColumnModel().getColumn(6).setCellRenderer(alinearderecha);
        jt_vengenxmes.getColumnModel().getColumn(7).setCellRenderer(alinearderecha);
      

    }

  private void iniciar_modelo_de_tabla()
    {

        jtable_modelo=new javax.swing.table.DefaultTableModel();//Creo el modelo
        jtable_modelo.addColumn("<html><b>Clasif.</b></html>");
        jtable_modelo.addColumn("<html><b>Proveedor</b></html>");
        jtable_modelo.addColumn("<html><b>F.Ult.Compra</b></html>");
        jtable_modelo.addColumn("<html><b>Com. Piezas</b></html>");
        jtable_modelo.addColumn("<html><b>Com. Costo</b></html>");
        jtable_modelo.addColumn("<html><b>com. Precio</b></html>");
        jtable_modelo.addColumn("<html><b>Vent. Piezas</b></html>");
        jtable_modelo.addColumn("<html><b>Vent. Costo</b></html>");
        jtable_modelo.addColumn("<html><b>Vent. Precio</b></html>");
        jtable_modelo.addColumn("<html><b>% Vendido.</b></html>");
   }

private void iniciar_modelo_ventasxmes()
    {
         jtable_modelo_ventasxmes=new javax.swing.table.DefaultTableModel();//Creo el modelo
         jtable_modelo_ventasxmes.addColumn("<html><b>Mes</b></html>");
         jtable_modelo_ventasxmes.addColumn("<html><b>Pz Compra</b></html>");
         jtable_modelo_ventasxmes.addColumn("<html><b>Costo Compra</b></html>");
         jtable_modelo_ventasxmes.addColumn("<html><b>Piezas v</b></html>");
         jtable_modelo_ventasxmes.addColumn("<html><b>Costo v</b></html>");
         jtable_modelo_ventasxmes.addColumn("<html><b>Importe V</b></html>");
         jtable_modelo_ventasxmes.addColumn("<html><b>Utilidad</b></html>");
         jtable_modelo_ventasxmes.addColumn("<html><b>D/C</b></html>");

   }

 
 private void iniciar_modelo_periodos()
    {

        jtable_modelo_periodo=new javax.swing.table.DefaultTableModel();//Creo el modelo
        jtable_modelo_periodo.addColumn("<html><b>Proveedor</b></html>");
        jtable_modelo_periodo.addColumn("<html><b>% Vendido</b></html>");

   }
  private void iniciar_modelo_periodosde()
    {

        jtable_modelo_periodode=new javax.swing.table.DefaultTableModel();//Creo el modelo
        jtable_modelo_periodode.addColumn("<html><b>Periodo</b></html>");
        jtable_modelo_periodode.addColumn("<html><b>Entrada</b></html>");
        jtable_modelo_periodode.addColumn("<html><b>Costo</b></html>");
        jtable_modelo_periodode.addColumn("<html><b>Cant. Vendida</b></html>");
        jtable_modelo_periodode.addColumn("<html><b>Costo V.</b></html>");
        jtable_modelo_periodode.addColumn("<html><b>Importe V.</b></html>");
        jtable_modelo_periodode.addColumn("<html><b>Utilidad</b></html>");
        jtable_modelo_periodode.addColumn("<html><b>% Rot</b></html>");

   }

 private void iniciar_modelo_artiyesta()
    {
        jtable_modelo_articyestadis=new javax.swing.table.DefaultTableModel();//Creo el modelo
        jtable_modelo_articyestadis.addColumn("<html><b>Temp. Ent./Familia</b></html>");
        jtable_modelo_articyestadis.addColumn("<html><b>Id</b></html>");
        jtable_modelo_articyestadis.addColumn("<html><b>Descripcion/Item</b></html>");
        jtable_modelo_articyestadis.addColumn("<html><b>Costo</b></html>");
        jtable_modelo_articyestadis.addColumn("<html><b>Precio</b></html>");
        jtable_modelo_articyestadis.addColumn("<html><b>F.Compra</b></html>");
        jtable_modelo_articyestadis.addColumn("<html><b>P.Vendidas</b></html>");
        jtable_modelo_articyestadis.addColumn("<html><b>Exist.</b></html>");
        jtable_modelo_articyestadis.addColumn("<html><b>Rot.</b></html>");
   }

 private void iniciar_modelo_articuloestadistica()
 {
        jtable_modelo_estadisticas=new javax.swing.table.DefaultTableModel();//Creo el modelo
        jtable_modelo_estadisticas.addColumn("<html><BODY><b>Tienda</b></BODY></html>");
        jtable_modelo_estadisticas.addColumn("<html><BODY><b>C.Surt</b></BODY></html>");
        jtable_modelo_estadisticas.addColumn("<html><BODY><b>Pzas E.</b></BODY></html>");
        jtable_modelo_estadisticas.addColumn("<html><BODY><b>P.Vend</b></BODY></html>");
        jtable_modelo_estadisticas.addColumn("<html><BODY><b>f.P.Venta</b></BODY></html>");
        jtable_modelo_estadisticas.addColumn("<html><BODY><b>f.U.Venta</b></BODY></html>");
        jtable_modelo_estadisticas.addColumn("<html><BODY><b>E.Min</b></BODY></html>");
        jtable_modelo_estadisticas.addColumn("<html><BODY><b>E.max</b></BODY></html>");
        jtable_modelo_estadisticas.addColumn("<html><BODY><b>Exist.</b></BODY></html>");

}

private void cargar_datosarticulosexisyacum(int opcion,String textob1,String textob2)
{
      //inicio proceso para informar de las promociones en cada tienda
            //INICIO PROCESO PARA INFORMAR DE LAS PROMOCIONES EN CADA TIENDA
 //inicio proceso para informar de las promociones en cada tienda
            //INICIO PROCESO PARA INFORMAR DE LAS PROMOCIONES EN CADA TIENDA
     while(jtable_modelo.getRowCount()>0)jtable_modelo.removeRow(0);
     while(jtable_modelo_periodo.getRowCount()>0)jtable_modelo_periodo.removeRow(0);

            String texto="",texto2="";
            java.util.Date fechainicial=new Date();
            ResultSet rs2 = null;
             float pzasc=0,importec=0,importep=0,piezasv=0,importecv=0,importepv=0;
            DecimalFormat myForma = new DecimalFormat("###,###,###,###");
            String htmlabre="<html><BODY>",htmlcierra="</BODY></html>",colorabre="",colorcierra="";
           // this.LimpiarJTable();

            Object[] fnewRow = new Object[10],fnewRow2 = new Object[2];



        switch (opcioncons)
                    {
                    case 2:
                            texto2="select * from x1distribucion_proveedor_compras_vs_ventas("+opcioncons+",'"+textob1+"','"+textob2+"') as (id_pro character varying(12), descrip_prove character varying(60), clasificacion character varying(10), fecha_ult_venta date,  inicial_prove character varying(20), descrip_clasif character varying(40), acumuladopiezas numeric,acumuladoimporte numeric, acumuladoprecio numeric, subfam_arti smallint, cantidad_producto real, importecosto double precision, importe_neto double precision);";
                    break;
                    case 4:
                            texto2="select * from x1distribucion_proveedor_compras_vs_ventas("+opcioncons+",'"+textob1+"','"+textob2+"') as (id_pro character varying(12), descrip_prove character varying(60), clasificacion character varying(10), fecha_ult_venta date,  inicial_prove character varying(20), descrip_clasif character varying(40), acumuladopiezas numeric,acumuladoimporte numeric, acumuladoprecio numeric, subfam_arti smallint, cantidad_producto numeric, importecosto numeric, importe_neto numeric);";
                    break;
                    }

            System.out.println(texto2);
                        try{
                                  rs2 = x.sieuno_executediversosv2(texto2,variables_global.getconexiongral());
                                  while (rs2.next())
                                    {
                                      //System.out.println("aqui va:"+rs2.getString("id_pro"));

                                      fnewRow[0]=""+rs2.getString("clasificacion")+":"+rs2.getString("descrip_clasif");
                                      fnewRow[1]=""+rs2.getString("id_pro")+":"+rs2.getString("descrip_prove")+":"+rs2.getString("subfam_arti")+"";
                                      if (rs2.getString("fecha_ult_venta")!= null)
                                        {
                                            fnewRow[2]=""+this.fechaeuropea(rs2.getString("fecha_ult_venta"))+"";
                                        }
                                      else
                                        {
                                            fnewRow[2]="";
                                        }
                                      if (rs2.getString("acumuladopiezas")!= null)
                                        {
                                            fnewRow[3]=myForma.format(rs2.getFloat("acumuladopiezas"));
                                            fnewRow[4]=myForma.format(rs2.getFloat("acumuladoimporte"));
                                            fnewRow[5]=myForma.format(rs2.getFloat("acumuladoprecio"));

                                            fnewRow[6]=myForma.format(rs2.getFloat("cantidad_producto"));
                                            fnewRow[7]=myForma.format(rs2.getFloat("importecosto"));
                                            fnewRow[8]=myForma.format(rs2.getFloat("importe_neto"));
                                            fnewRow[9]=myForma.format((rs2.getFloat("importecosto")/rs2.getFloat("acumuladoimporte")*100))+"%";

                                            pzasc+=rs2.getFloat("acumuladopiezas");
                                            importec+=rs2.getFloat("acumuladoimporte");
                                            importep+=rs2.getFloat("acumuladoprecio");

                                            piezasv+=rs2.getFloat("cantidad_producto");
                                            importecv+=rs2.getFloat("importecosto");
                                            importepv+=rs2.getFloat("importe_neto");

                                        }
                                      else
                                        {
                                            fnewRow[3]="";
                                            fnewRow[4]="";
                                            fnewRow[5]="";

                                            fnewRow[6]="";
                                            fnewRow[7]="";
                                            fnewRow[8]="";
                                            fnewRow[9]="";
                                        }                
                                      
                                       fnewRow2[0]=""+rs2.getString("id_pro")+":"+rs2.getString("subfam_arti")+":"+rs2.getString("descrip_prove");
                                       fnewRow2[1]=myForma.format((rs2.getFloat("importecosto")/rs2.getFloat("acumuladoimporte"))*100)+"%";
                                      jtable_modelo.addRow(fnewRow);
                     
                                      jtable_modelo_periodo.addRow(fnewRow2);
                                    }//consulto la bd
                          }
                          catch(Exception e)
                          {
                                    System.out.println(e.getMessage());
                          }

                                    fnewRow[0]="";
                                    fnewRow[1]="<html><h3>Fecha:"+this.fechaeuropea(fechahoy)+"Totales</h3></html>";
                                    fnewRow[2]="";

                                    fnewRow[3]="<html><h3>"+myForma.format(pzasc)+"</h3></html>";
                                    fnewRow[4]="<html><h3>"+myForma.format(importec)+"</h3></html>";
                                    fnewRow[5]="<html><h3>"+myForma.format(importep)+"</h3></html>";

                                    fnewRow[6]="<html><h3>"+myForma.format(piezasv)+"</h3></html>";
                                    fnewRow[7]="<html><h3>"+myForma.format(importecv)+"</h3></html>";
                                    fnewRow[8]="<html><h3>"+myForma.format(importepv)+"</h3></html>";
                                    fnewRow[9]="<html><h3>"+myForma.format((importecv/importec)*100)+"%"+"</h3></html>";

                                    jtable_modelo.addRow(fnewRow);

                this.centrar_datos();
}
private void loadcomboclasif(){
this.jcbx_clasificacion.addItem("0:General");

            try
            {
                  rs = x.sieuno_executediversosv2("select * from x1distribucion_terminados_proveed_clasif(0,0,'') as (id character varying(10),descripclasif character varying(40),clasifobser character varying(30));",variables_global.getconexiongral());
               while (rs.next())
                    {
                      this.jcbx_clasificacion.addItem(rs.getString("id")+":"+rs.getString("descripclasif"));
                    }
             }
            catch(Exception e)
            {
                System.out.println(e.getMessage());
            }
    }

private void cargar_datosventaxmes(String subf)
{
      //inicio proceso para informar de las promociones en cada tienda
            //INICIO PROCESO PARA INFORMAR DE LAS PROMOCIONES EN CADA TIENDA
    while(jtable_modelo_ventasxmes.getRowCount()>0)jtable_modelo_ventasxmes.removeRow(0);
            String texto="",texto2="";
            java.util.Date fechainicial=new Date();
            ResultSet rs2 = null;
             float importe=0,importe2=0,acumulado=0,piezas=0,piezas2=0;
            DecimalFormat myForma = new DecimalFormat("###,###,###,###");
            Object[] fnewRow = new Object[9];
                 importe=0;
                       texto2="select * from x1sieuno_articulo_ventasxsubfammensual("+subf+") as (fecha date,fe text,subfam integer,piezas real, importeneto double precision,importecosto double precision,utili double precision);";
                            System.out.println(texto2);
                            try{
                                  rs2 = x.sieuno_executediversosv2(texto2,variables_global.getconexiongral());
                                  while (rs2.next())
                                    {
                                      fnewRow[0]="<html><h4><b>"+rs2.getString("fe")+"</b></h4></html>";
                                       fnewRow[1]="0";
                                        fnewRow[2]="0";
                                      fnewRow[3]=""+myForma.format(rs2.getFloat("piezas"))+"";
                                      fnewRow[4]=""+myForma.format(rs2.getFloat("importecosto"))+"";
                                      fnewRow[5]=""+myForma.format(rs2.getFloat("importeneto"))+"";
                                      fnewRow[6]=""+myForma.format(rs2.getFloat("utili"))+"";
                                      if(rs2.getFloat("utili") > 0 )
                                        {
                                          fnewRow[7]=""+myForma.format((rs2.getFloat("utili")/rs2.getFloat("importecosto"))*100)+"";
                                        }
                                      else{
                                          fnewRow[7]="";
                                      }
                                      fnewRow[8]="0";
                                      piezas+=rs2.getFloat("piezas");
                                      totalcostovendido+=rs2.getFloat("importecosto");
                                      jtable_modelo_ventasxmes.addRow(fnewRow);
                                      importe+=rs2.getFloat("importecosto");
                                      importe2+=rs2.getFloat("importeneto");
                                      acumulado+=rs2.getFloat("utili");
                                    }//consulto la bd
                                }
                            catch(Exception e)
                                {
                                    System.out.println(e.getMessage());
                                }
                                    fnewRow[0]="<html><h4><b>"+this.jtf_proveedornombre.getText()+"TOTAL:</b></h4></html>";
                                      fnewRow[1]="0";
                                      fnewRow[2]="0";
                                      fnewRow[3]="<html><h4><b>"+myForma.format(piezas)+"</b></h4></html";
                                      fnewRow[4]="<html><h4><b>"+myForma.format(importe)+"</b></h4></html";
                                      fnewRow[5]="<html><h4><b>"+myForma.format(importe2)+"</b></h4></html";
                                      fnewRow[6]="<html><h4><b>"+myForma.format(acumulado)+"</b></h4></html";
                                      fnewRow[7]="";
 jtable_modelo_ventasxmes.addRow(fnewRow);
}

private void cargar_datoscomprasxmes(String subf)
{
      //inicio proceso para informar de las promociones en cada tienda
            //INICIO PROCESO PARA INFORMAR DE LAS PROMOCIONES EN CADA TIENDA
            String texto="",texto2="";
            java.util.Date fechainicial=new Date();
            ResultSet rs2 = null;
             float importe=0,importe2=0,acumulado=0,piezas=0,piezas2=0;
            DecimalFormat myForma = new DecimalFormat("###,###,###,###");

                 importe=0;
                       texto2="select * from x1distribucion_compras_subfamxmes("+subf+")  as (fecha date,fe text,subfam smallint,piezas numeric, importeneto numeric);";

                            System.out.println(texto2);
                            try{
                                  rs2 = x.sieuno_executediversosv2(texto2,variables_global.getconexiongral());
                                  while (rs2.next())
                                    {
                                     this.crea_historico_compras(rs2.getString("fe"),myForma.format(rs2.getFloat("piezas")),myForma.format(rs2.getFloat("importeneto")));
                                     importe+=rs2.getFloat("piezas");
                                     importe2+=rs2.getFloat("importeneto");
                                    }//consulto la bd
                                }
                            catch(Exception e)
                                {
                                    System.out.println(e.getMessage());
                                }
                            jtable_modelo_ventasxmes.setValueAt("<html><h4><b>"+myForma.format(importe)+"</b></h4></html",this.jtable_modelo_ventasxmes.getRowCount()-1 ,1);
                            jtable_modelo_ventasxmes.setValueAt("<html><h4><b>"+myForma.format(importe2)+"</b></h4></html",this.jtable_modelo_ventasxmes.getRowCount()-1 ,2);





}

private void crea_historico_compras(String idempleado,String pz,String costo)
    {
        int numerofilas=this.jtable_modelo_ventasxmes.getRowCount();
        String empleadoactual="",iddepto[]=null;
        int numerocolumnas=jt_vengenxmes.getColumnModel().getColumnCount(),ii=00,encontrado=0;
        Object[] fnewRow = new Object[numerocolumnas];

       //invoco al metodo que trae el recordset de datos
        for( ii=0;ii<numerofilas;ii++)
                {
                    empleadoactual=jtable_modelo_ventasxmes.getValueAt(ii, 0).toString().replace("<html><h4><b>", "").replace("</b></h4></html>", "");
                     if (empleadoactual.equals(idempleado))
                        {
                            encontrado=1;
                            jtable_modelo_ventasxmes.setValueAt(pz,ii ,1);
                            jtable_modelo_ventasxmes.setValueAt(costo,ii ,2);
                        }
                }
       if(encontrado==0)
            {
                 fnewRow[0]=idempleado;
                  fnewRow[1]=pz;
                   fnewRow[2]=costo;
                 for(ii=3;ii<numerocolumnas;ii++)
                            {

                                        fnewRow[ii]="0";
                             }
             jtable_modelo_ventasxmes.addRow(fnewRow);
            }
    }

private void cargar_datosarticulosexisyacumdet(int opcion,String esquema,String subf)
{
            String texto="",texto2="",htmlabre="<html><BODY>",htmlcierra="</BODY></html>",colorabre="",colorcierra="";
            java.util.Date fechainicial=new Date();
            ResultSet rs2 = null;
             float importe=0,importe2=0,acumulado=0,piezas=0,piezas2=0,apiezas=0,apiezas2=0;
            DecimalFormat myForma = new DecimalFormat("###,###,###,###"),myForma2 = new DecimalFormat("###,###,###,###.##"),myForma3 = new DecimalFormat("############.##");

           while(jtable_modelo_articyestadis.getRowCount()>0)jtable_modelo_articyestadis.removeRow(0);

            Object[] fnewRow = new Object[9];
                 importe=0;
                  if(opcion==1)
                         {
                             switch (opcioncons)
                                       {
                                    case 4:
                                            texto2="select * from x1sieuno_articulo_exist_y_acumventasv2(5,'"+esquema+"','"+subf+"') as (id integer, clave_producto character varying(16),cod_barra character varying(16), descripcion character varying(80), ultimo_cos numeric,id_familia integer,id_subfam integer, item character varying(80), precio_1 numeric, fecha_ult_com date, idtempoingreso smallint,idtempoventa smallint,idlinea smallint,nombrefamilia character varying(30),nombresubfamilia character varying(50),nombretemporada character varying(25),nombrelinea character varying(25),existencia numeric,cantidadvendida numeric,descritemventa character varying(25));";
                                     break;
                                     case 2:
                                            texto2="select * from x1sieuno_articulo_exist_y_acumventasv2(1,'"+esquema+"','"+subf+"') as (id integer, clave_producto character varying(16),cod_barra character varying(16), descripcion character varying(80), ultimo_cos numeric,id_familia integer,id_subfam integer, item character varying(80), precio_1 numeric, fecha_ult_com date, idtempoingreso smallint,idtempoventa smallint,idlinea smallint,nombrefamilia character varying(30),nombresubfamilia character varying(50),nombretemporada character varying(25),nombrelinea character varying(25),existencia double precision,cantidadvendida real,descritemventa character varying(25));";
                                    break;
                                    }
                            }


                            System.out.println(texto2);
                            try{
                                  rs2 = x.sieuno_executediversosv2(texto2,variables_global.getconexiongral());
                                  while (rs2.next())
                                    {
                                      fnewRow[0]=""+rs2.getString("nombrefamilia")+"/"+rs2.getString("nombretemporada");
                                      fnewRow[1]=""+rs2.getString("id")+":"+rs2.getString("clave_producto")+"";
                                      fnewRow[2]=""+rs2.getString("descripcion")+":"+rs2.getString("item");
                                      fnewRow[3]=""+myForma3.format(rs2.getFloat("ultimo_cos"))+"";
                                      fnewRow[4]=""+myForma.format(rs2.getFloat("precio_1"))+"";
                                      fnewRow[5]=""+this.fechaeuropea(rs2.getString("fecha_ult_com"))+"";
                                      fnewRow[6]=""+rs2.getString("cantidadvendida")+"";
                                      fnewRow[7]=""+rs2.getString("existencia")+"";
                                      piezas=rs2.getFloat("cantidadvendida");
                                      piezas2=rs2.getFloat("existencia");
                                      acumulado=piezas+piezas2;
                                      importe=(piezas/acumulado)*100;
                                       apiezas+=rs2.getFloat("cantidadvendida");
                                      apiezas2+=rs2.getFloat("existencia");
                                       colorabre="";
                                       colorcierra="";
                                    if (importe<=50)
                                        {
                                            colorabre="<b><font color=#CC0000>";
                                            colorcierra="<font></b>";
                                        }
                                    if ((importe>50) && (importe<=75))
                                            {
                                                colorabre="<b><font color=#FF6633>";
                                                colorcierra="<font></b>";
                                            }
                                      if (importe>75)
                                            {
                                                colorabre="<b><font color=#00FF00>";
                                                colorcierra="<font></b>";
                                            }
                                      fnewRow[8]=htmlabre+colorabre+myForma.format(importe)+"%"+colorcierra+htmlcierra;
                                      jtable_modelo_articyestadis.addRow(fnewRow);
                                    }//consulto la bd
                                }
                            catch(Exception e)
                                {
                                    System.out.println(e.getMessage());
                                }
                                        fnewRow[0]="Fecha:"+this.fechaeuropea(fechahoy);
                                      fnewRow[1]="";
                                      fnewRow[2]="";
                                      fnewRow[3]="";
                                      fnewRow[4]="";
                                      fnewRow[5]="Ent="+myForma2.format(apiezas+apiezas2);
                                        fnewRow[6]=""+myForma2.format(apiezas)+"";
                                      fnewRow[7]=""+myForma2.format(apiezas2)+"";

                                      acumulado=apiezas+apiezas2;
                                      importe=(apiezas/acumulado)*100;
                                       colorabre="";
                                       colorcierra="";
                                    if (importe<=50)
                                        {
                                            colorabre="<b><font color=#CC0000>";
                                            colorcierra="<font></b>";
                                        }
                                    if ((importe>50) && (importe<=75))
                                            {
                                                colorabre="<b><font color=#FF6633>";
                                                colorcierra="<font></b>";
                                            }
                                      if (importe>75)
                                            {
                                                colorabre="<b><font color=#00FF00>";
                                                colorcierra="<font></b>";
                                            }
                                      fnewRow[8]=htmlabre+colorabre+myForma.format(importe)+"%"+colorcierra+htmlcierra;
                                      jtable_modelo_articyestadis.addRow(fnewRow);


}

private void cargar_datos_periodo(int opcion,String esquema,String subf)
{
            String texto="",texto2="",htmlabre="<html><BODY>",htmlcierra="</BODY></html>",colorabre="",colorcierra="";
            java.util.Date fechainicial=new Date();
            ResultSet rs2 = null;
             float importe=0,importe2=0,acumulado=0,piezas=0,piezas2=0;
            DecimalFormat myForma = new DecimalFormat("###,###,###,###"),myForma2 = new DecimalFormat("###,###,###,###.##");

           while(jtable_modelo_periodode.getRowCount()>0)jtable_modelo_periodode.removeRow(0);

            Object[] fnewRow = new Object[8];
                 importe=0;
                 if(opcion==3)
                         {
                             switch (opcioncons)
                                       {
                                    case 4:
                                        texto2="select * from x1sieuno_articulo_exist_y_acumventasv2(4,'"+esquema+"','"+subf+"') as (id_subfam integer, idtempoingreso smallint,costo numeric,existencia numeric,cantidadvendida numeric,importeneto numeric,importecosto numeric,uti numeric,descritement character varying(25));";
                                     break;
                                     case 2:
                                        texto2="select * from x1sieuno_articulo_exist_y_acumventasv2(3,'"+esquema+"','"+subf+"') as (id_subfam integer, idtempoingreso smallint,costo double precision,existencia double precision,cantidadvendida real,importeneto double precision,importecosto double precision,uti double precision,descritement character varying(25));";
                                    break;
                                    }
                            }


                            System.out.println(texto2);
                            try{
                                  rs2 = x.sieuno_executediversosv2(texto2,variables_global.getconexiongral());
                                  while (rs2.next())
                                    {
                                      fnewRow[0]=""+rs2.getString("idtempoingreso")+":"+rs2.getString("descritement");
                                      fnewRow[1]=myForma.format(rs2.getFloat("existencia")+rs2.getFloat("cantidadvendida"));
                                      fnewRow[2]=myForma.format(rs2.getFloat("costo")+rs2.getFloat("importecosto"));
                                      fnewRow[3]=myForma.format(rs2.getFloat("cantidadvendida"));
                                      fnewRow[4]=myForma.format(rs2.getFloat("importecosto"));
                                      fnewRow[5]=myForma.format(rs2.getFloat("importeneto"));
                                      fnewRow[6]=myForma.format(rs2.getFloat("uti"));
                                      piezas=rs2.getFloat("cantidadvendida");
                                      piezas2=rs2.getFloat("existencia");
                                      acumulado=piezas+piezas2;
                                      importe=(piezas/acumulado)*100;
                                       colorabre="";
                                       colorcierra="";
                                    if (importe<=50)
                                        {
                                            colorabre="<b><font color=#CC0000>";
                                            colorcierra="<font></b>";
                                        }
                                    if ((importe>50) && (importe<=75))
                                            {
                                                colorabre="<b><font color=#FF6633>";
                                                colorcierra="<font></b>";
                                            }
                                      if (importe>75)
                                            {
                                                colorabre="<b><font color=#00FF00>";
                                                colorcierra="<font></b>";
                                            }
                                      fnewRow[7]=htmlabre+colorabre+myForma.format(importe)+"%"+colorcierra+htmlcierra;

                                      jtable_modelo_periodode.addRow(fnewRow);
                                    }//consulto la bd
                                }
                            catch(Exception e)
                                {
                                    System.out.println(e.getMessage());
                                }
                                        fnewRow[0]=""+this.jtf_proveedornombre2.getText();
                                        fnewRow[1]="Fecha:";
                                        fnewRow[2]=""+this.fechaeuropea(fechahoy);
                                        fnewRow[3]="";
                                        fnewRow[4]="";
                                        fnewRow[5]="";
                                        fnewRow[6]="";
                                        fnewRow[7]="";

                                      jtable_modelo_periodode.addRow(fnewRow);
}


private void carga_articulo_estadisticas(String idtienda,String idpro)
    {
            DecimalFormat miformat = new DecimalFormat("###,###,###,###");
            while(jtable_modelo_estadisticas.getRowCount()>0)jtable_modelo_estadisticas.removeRow(0);
            Object[] fnewRow = new Object[10];
            int diasdif=0,diasdifprimer=0,diasdifultimo=0;
            float totalexist=0;
            String idcadena[]=null;
            String texto2="select * from x1sieuno_articulo_ventas_estadisticasv3(0,"+idtienda+","+idpro+") as (ida integer,min integer,max integer,exi double precision,idp integer,cod text,cndt integer,descor text,preve double precision,pre_re real,clavepro text,acumventas real,primerv date,ultimav date,nmovent bigint,piezasent real,diasvsprimerventa integer,diasvsultimaventa integer,diasenvenderse integer)";
            java.util.Date fechaactual=new Date();
            try
                {
                 rs = x.sieuno_executediversosv2(texto2,variables_global.getconexiongral());
                          while (rs.next())
                            {
                                    idcadena=rs.getString("clavepro").toString().split(":");
                                    diasdif=0;
                                    diasdifprimer=0;
                                    diasdifultimo=0;
                                    fnewRow[0]=idcadena[2]+":"+idcadena[1];
                                    fnewRow[1]=miformat.format(rs.getFloat("nmovent"));
                                    fnewRow[2]=miformat.format(rs.getFloat("piezasent"));
                                    fnewRow[3]=miformat.format(rs.getFloat("acumventas")*-1);
                                    if(rs.getString("primerv") != null)
                                        {
                                            //diasdifprimer=this.fechasDiferenciaEnDias(this.fechadecadenaadate(rs.getString("primerv")),fechaactual);
                                            fnewRow[4]="<html>"+this.fechaeuropea(rs.getString("primerv"))+"<br>"+this.mensajetiempo(rs.getInt("diasvsprimerventa"))+"</html>";
                                            //diasdif=this.fechasDiferenciaEnDias(this.fechadecadenaadate(rs.getString("primerv")),this.fechadecadenaadate(rs.getString("ultimav")));
              
                                        }
                                    else
                                        {
                                            fnewRow[4]="";
                       
                                        }
                                    if(rs.getString("ultimav") != null)
                                        {
                                            //diasdifultimo=this.fechasDiferenciaEnDias(this.fechadecadenaadate(rs.getString("ultimav")),fechaactual);

                                            if(rs.getFloat("exi")<=0)
                                                {
                                                fnewRow[5]="<html><font color=\"red\">"+this.fechaeuropea(rs.getString("ultimav"))+"<br>Agotado"+this.mensajetiempo(rs.getInt("diasvsultimaventa"))+"</font></html>";
                                                    //fnewRow[12]="<html><font color=\"red\">"+"Agotado"+this.mensajetiempo(diasdifultimo)+"</font></html>";
                                                }
                                            else
                                                {
                                                fnewRow[5]="<html>"+this.fechaeuropea(rs.getString("ultimav"))+"<br>"+this.mensajetiempo(rs.getInt("diasvsultimaventa"))+"</html>";
                                                }
                                        }
                                    else
                                        {
                                            fnewRow[5]="";
                                        }
                                  
                                  
                                    fnewRow[6]=miformat.format(rs.getFloat("min"));
                                    fnewRow[7]=miformat.format(rs.getFloat("max"));
                                    fnewRow[8]=miformat.format(rs.getFloat("exi"));
                                    totalexist+=rs.getFloat("exi");
                                    jtable_modelo_estadisticas.addRow(fnewRow);
                            }
                }
                catch(Exception e)
                    {
                        System.out.println(e.getMessage());
                    }


}


 private String mensajetiempo(int nd) {
     String mensaje="";
     if (nd==0)
				{
					mensaje=" Hoy ";
				}
		if (nd==1)
				{
					mensaje=" ayer ";
				}
		if (nd>1)
				{
					mensaje=" Hace " + nd + " Dias " ;
				}
     if (nd<0)
				{
					mensaje=" Vence En " + nd + " Dias " ;
				}
 	return mensaje;
 }

private String  fechaeuropea(String fecha) {

         //resibe cadena de fecha en formato americano yyyy-MM-dd
        java.util.Date fechaestaeuropa=null;
       SimpleDateFormat formateadorestaeuropa = new SimpleDateFormat("dd-MM-yyyy");
       String cadenafecha="";
        try
         {
          fechaestaeuropa = formateadoresta.parse(fecha);
         }
        catch (ParseException e)
          {
             //Error, la cadena de texto no se puede convertir en fecha.
          }
       cadenafecha= formateadorestaeuropa.format(fechaestaeuropa);
       return cadenafecha;

    }
private String  fechaeuropea(Date fecha) {
       SimpleDateFormat formateadorestaeuropa = new SimpleDateFormat("dd-MM-yyyy");
       String cadenafecha="";
       cadenafecha= formateadorestaeuropa.format(fecha);
       return cadenafecha;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        jPanel2 = new javax.swing.JPanel();
        jbtn_salir = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jbtn_buscar = new javax.swing.JButton();
        jcbx_clasificacion = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();
        jrbn_repguar = new javax.swing.JRadioButton();
        jrbn_repcontruye = new javax.swing.JRadioButton();
        jLabel4 = new javax.swing.JLabel();
        jrbn_vscompras = new javax.swing.JRadioButton();
        jrbn_vsexistencia = new javax.swing.JRadioButton();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtb_provee_comvsventas = new javax.swing.JTable()
        {
            public boolean isCellEditable(int rowIndex, int mColIndex) {
                return false;
            }}

            ;
            jPanel7 = new javax.swing.JPanel();
            jScrollPane5 = new javax.swing.JScrollPane();
            jtb_provee_comvsventas3 = new javax.swing.JTable()
            {
                public boolean isCellEditable(int rowIndex, int mColIndex) {
                    return false;
                }}

                ;
                jTabbedPane2 = new javax.swing.JTabbedPane();
                jPanel5 = new javax.swing.JPanel();
                jScrollPane4 = new javax.swing.JScrollPane();
                jt_vengenxmes = new javax.swing.JTable()
                {
                    public boolean isCellEditable(int rowIndex, int mColIndex) {
                        return false;
                    }}

                    ;
                    jtf_proveedornombre = new javax.swing.JTextField();
                    jLabel1 = new javax.swing.JLabel();
                    jPanel8 = new javax.swing.JPanel();
                    jScrollPane7 = new javax.swing.JScrollPane();
                    jt_vengenxmes1 = new javax.swing.JTable()
                    {
                        public boolean isCellEditable(int rowIndex, int mColIndex) {
                            return false;
                        }}

                        ;
                        jtf_proveedornombre2 = new javax.swing.JTextField();
                        jLabel3 = new javax.swing.JLabel();
                        jtf_idactual = new javax.swing.JTextField();
                        jPanel9 = new javax.swing.JPanel();
                        jScrollPane6 = new javax.swing.JScrollPane();
                        jt_articulosestadisticas = new javax.swing.JTable()
                        {
                            public boolean isCellEditable(int rowIndex, int mColIndex) {
                                return false;
                            }
                        }
                        ;
                        jtf_proveedornombre1 = new javax.swing.JTextField();
                        jLabel2 = new javax.swing.JLabel();
                        jPanel24 = new javax.swing.JPanel();
                        jScrollPane16 = new javax.swing.JScrollPane();
                        jtbl_estadisticasarticulo1 = new javax.swing.JTable(){
                            public boolean isCellEditable(int rowIndex, int mColIndex) {
                                return false;
                            }}
                            ;
                            jtf_proveedornombre3 = new javax.swing.JTextField();
                            jTextField1 = new javax.swing.JTextField();
                            jLabel5 = new javax.swing.JLabel();
                            jTextField2 = new javax.swing.JTextField();
                            jLabel6 = new javax.swing.JLabel();
                            jMenuBar1 = new javax.swing.JMenuBar();
                            jMenu1 = new javax.swing.JMenu();
                            jmni_salir = new javax.swing.JMenuItem();
                            jMenu2 = new javax.swing.JMenu();
                            jmni_escape = new javax.swing.JMenuItem();
                            jMenuItem1 = new javax.swing.JMenuItem();
                            jMenuItem2 = new javax.swing.JMenuItem();

                            setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
                            org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(sie_invdis.Sie_invdisApp.class).getContext().getResourceMap(com_distri_provee_comp_vs_ven.class);
                            setTitle(resourceMap.getString("Form.title")); // NOI18N
                            setName("Form"); // NOI18N

                            jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
                            jPanel2.setName("jPanel2"); // NOI18N

                            jbtn_salir.setIcon(resourceMap.getIcon("jbtn_salir.icon")); // NOI18N
                            jbtn_salir.setText(resourceMap.getString("jbtn_salir.text")); // NOI18N
                            jbtn_salir.setName("jbtn_salir"); // NOI18N
                            jbtn_salir.addActionListener(new java.awt.event.ActionListener() {
                                public void actionPerformed(java.awt.event.ActionEvent evt) {
                                    jbtn_salirActionPerformed(evt);
                                }
                            });

                            javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
                            jPanel2.setLayout(jPanel2Layout);
                            jPanel2Layout.setHorizontalGroup(
                                jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                                    .addContainerGap(951, Short.MAX_VALUE)
                                    .addComponent(jbtn_salir)
                                    .addContainerGap())
                            );
                            jPanel2Layout.setVerticalGroup(
                                jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jbtn_salir)
                            );

                            jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel3.border.title"))); // NOI18N
                            jPanel3.setName("jPanel3"); // NOI18N

                            jbtn_buscar.setIcon(resourceMap.getIcon("jbtn_buscar.icon")); // NOI18N
                            jbtn_buscar.setText(resourceMap.getString("jbtn_buscar.text")); // NOI18N
                            jbtn_buscar.setName("jbtn_buscar"); // NOI18N
                            jbtn_buscar.addActionListener(new java.awt.event.ActionListener() {
                                public void actionPerformed(java.awt.event.ActionEvent evt) {
                                    jbtn_buscarActionPerformed(evt);
                                }
                            });

                            jcbx_clasificacion.setName("jcbx_clasificacion"); // NOI18N

                            jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
                            jLabel7.setName("jLabel7"); // NOI18N

                            buttonGroup1.add(jrbn_repguar);
                            jrbn_repguar.setText(resourceMap.getString("jrbn_repguar.text")); // NOI18N
                            jrbn_repguar.setToolTipText(resourceMap.getString("jrbn_repguar.toolTipText")); // NOI18N
                            jrbn_repguar.setActionCommand(resourceMap.getString("jrbn_repguar.actionCommand")); // NOI18N
                            jrbn_repguar.setName("jrbn_repguar"); // NOI18N
                            jrbn_repguar.addActionListener(new java.awt.event.ActionListener() {
                                public void actionPerformed(java.awt.event.ActionEvent evt) {
                                    jrbn_repguarActionPerformed(evt);
                                }
                            });

                            buttonGroup1.add(jrbn_repcontruye);
                            jrbn_repcontruye.setText(resourceMap.getString("jrbn_repcontruye.text")); // NOI18N
                            jrbn_repcontruye.setToolTipText(resourceMap.getString("jrbn_repcontruye.toolTipText")); // NOI18N
                            jrbn_repcontruye.setActionCommand(resourceMap.getString("jrbn_repcontruye.actionCommand")); // NOI18N
                            jrbn_repcontruye.setName("jrbn_repcontruye"); // NOI18N
                            jrbn_repcontruye.addActionListener(new java.awt.event.ActionListener() {
                                public void actionPerformed(java.awt.event.ActionEvent evt) {
                                    jrbn_repcontruyeActionPerformed(evt);
                                }
                            });

                            jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
                            jLabel4.setName("jLabel4"); // NOI18N

                            buttonGroup2.add(jrbn_vscompras);
                            jrbn_vscompras.setText(resourceMap.getString("jrbn_vscompras.text")); // NOI18N
                            jrbn_vscompras.setToolTipText(resourceMap.getString("jrbn_vscompras.toolTipText")); // NOI18N
                            jrbn_vscompras.setActionCommand(resourceMap.getString("jrbn_vscompras.actionCommand")); // NOI18N
                            jrbn_vscompras.setName("jrbn_vscompras"); // NOI18N
                            jrbn_vscompras.addActionListener(new java.awt.event.ActionListener() {
                                public void actionPerformed(java.awt.event.ActionEvent evt) {
                                    jrbn_vscomprasActionPerformed(evt);
                                }
                            });

                            buttonGroup2.add(jrbn_vsexistencia);
                            jrbn_vsexistencia.setText(resourceMap.getString("jrbn_vsexistencia.text")); // NOI18N
                            jrbn_vsexistencia.setToolTipText(resourceMap.getString("jrbn_vsexistencia.toolTipText")); // NOI18N
                            jrbn_vsexistencia.setActionCommand(resourceMap.getString("jrbn_vsexistencia.actionCommand")); // NOI18N
                            jrbn_vsexistencia.setName("jrbn_vsexistencia"); // NOI18N
                            jrbn_vsexistencia.addActionListener(new java.awt.event.ActionListener() {
                                public void actionPerformed(java.awt.event.ActionEvent evt) {
                                    jrbn_vsexistenciaActionPerformed(evt);
                                }
                            });

                            javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
                            jPanel3.setLayout(jPanel3Layout);
                            jPanel3Layout.setHorizontalGroup(
                                jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel3Layout.createSequentialGroup()
                                    .addContainerGap()
                                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 269, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(18, 18, 18)
                                    .addComponent(jLabel7)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jcbx_clasificacion, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(63, 63, 63)
                                    .addComponent(jbtn_buscar, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jrbn_vscompras)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jrbn_vsexistencia)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 66, Short.MAX_VALUE)
                                    .addComponent(jrbn_repguar)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jrbn_repcontruye)
                                    .addContainerGap())
                            );
                            jPanel3Layout.setVerticalGroup(
                                jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jcbx_clasificacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jrbn_repcontruye)
                                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel7)
                                    .addComponent(jrbn_repguar)
                                    .addComponent(jbtn_buscar)
                                    .addComponent(jrbn_vsexistencia)
                                    .addComponent(jrbn_vscompras))
                            );

                            jTabbedPane1.setName("jTabbedPane1"); // NOI18N

                            jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
                            jPanel1.setName("jPanel1"); // NOI18N

                            jScrollPane1.setName("jScrollPane1"); // NOI18N

                            jtb_provee_comvsventas.setFont(resourceMap.getFont("jtb_provee_comvsventas.font")); // NOI18N
                            jtb_provee_comvsventas.setModel(this.jtable_modelo);
                            jtb_provee_comvsventas.setName("jtb_provee_comvsventas"); // NOI18N
                            jtb_provee_comvsventas.setRowHeight(24);
                            jtb_provee_comvsventas.addMouseListener(new java.awt.event.MouseAdapter() {
                                public void mouseClicked(java.awt.event.MouseEvent evt) {
                                    jtb_provee_comvsventasMouseClicked(evt);
                                    if(evt.getClickCount() >= 2)
                                    {
                                        dioclick(evt);
                                        //System.out.println(" double click" );
                                    }
                                    if(evt.getClickCount() >= 1)
                                    {
                                        dioclickp(evt);
                                        //System.out.println(" double click" );
                                    }
                                }
                            });
                            jScrollPane1.setViewportView(jtb_provee_comvsventas);

                            javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
                            jPanel1.setLayout(jPanel1Layout);
                            jPanel1Layout.setHorizontalGroup(
                                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 1029, Short.MAX_VALUE)
                            );
                            jPanel1Layout.setVerticalGroup(
                                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE)
                                    .addContainerGap())
                            );

                            jTabbedPane1.addTab(resourceMap.getString("jPanel1.TabConstraints.tabTitle"), jPanel1); // NOI18N

                            jPanel7.setName("jPanel7"); // NOI18N

                            jScrollPane5.setName("jScrollPane5"); // NOI18N

                            jtb_provee_comvsventas3.setFont(resourceMap.getFont("jtb_provee_comvsventas3.font")); // NOI18N
                            jtb_provee_comvsventas3.setModel(this.jtable_modelo_periodo);
                            jtb_provee_comvsventas3.setName("jtb_provee_comvsventas3"); // NOI18N
                            jtb_provee_comvsventas3.setRowHeight(22);
                            jtb_provee_comvsventas3.addMouseListener(new java.awt.event.MouseAdapter() {
                                public void mouseClicked(java.awt.event.MouseEvent evt) {
                                    jtb_provee_comvsventas3MouseClicked(evt);
                                    if(evt.getClickCount() >= 1)
                                    {
                                        dioclickper(evt);
                                        //System.out.println(" double click" );
                                    }
                                }
                            });
                            jScrollPane5.setViewportView(jtb_provee_comvsventas3);

                            jTabbedPane2.setName("jTabbedPane2"); // NOI18N
                            jTabbedPane2.addChangeListener(new javax.swing.event.ChangeListener() {
                                public void stateChanged(javax.swing.event.ChangeEvent evt) {
                                    jTabbedPane2StateChanged(evt);
                                }
                            });

                            jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel5.border.title"))); // NOI18N
                            jPanel5.setName("jPanel5"); // NOI18N

                            jScrollPane4.setName("jScrollPane4"); // NOI18N

                            jt_vengenxmes.setModel(this.jtable_modelo_ventasxmes);
                            jt_vengenxmes.setName("jt_vengenxmes"); // NOI18N
                            jt_vengenxmes.setRowHeight(22);
                            jScrollPane4.setViewportView(jt_vengenxmes);

                            jtf_proveedornombre.setFont(resourceMap.getFont("jtf_proveedornombre.font")); // NOI18N
                            jtf_proveedornombre.setText(resourceMap.getString("jtf_proveedornombre.text")); // NOI18N
                            jtf_proveedornombre.setName("jtf_proveedornombre"); // NOI18N

                            jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
                            jLabel1.setName("jLabel1"); // NOI18N

                            javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
                            jPanel5.setLayout(jPanel5Layout);
                            jPanel5Layout.setHorizontalGroup(
                                jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel5Layout.createSequentialGroup()
                                    .addComponent(jLabel1)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jtf_proveedornombre, javax.swing.GroupLayout.PREFERRED_SIZE, 383, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addContainerGap(320, Short.MAX_VALUE))
                                .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 761, Short.MAX_VALUE)
                            );
                            jPanel5Layout.setVerticalGroup(
                                jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel5Layout.createSequentialGroup()
                                    .addContainerGap()
                                    .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(jtf_proveedornombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jLabel1))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 339, Short.MAX_VALUE))
                            );

                            jTabbedPane2.addTab(resourceMap.getString("jPanel5.TabConstraints.tabTitle"), jPanel5); // NOI18N

                            jPanel8.setBorder(javax.swing.BorderFactory.createEtchedBorder());
                            jPanel8.setName("jPanel8"); // NOI18N

                            jScrollPane7.setName("jScrollPane7"); // NOI18N

                            jt_vengenxmes1.setModel(this.jtable_modelo_periodode);
                            jt_vengenxmes1.setName("jt_vengenxmes1"); // NOI18N
                            jt_vengenxmes1.setRowHeight(22);
                            jScrollPane7.setViewportView(jt_vengenxmes1);

                            jtf_proveedornombre2.setFont(resourceMap.getFont("jtf_proveedornombre2.font")); // NOI18N
                            jtf_proveedornombre2.setName("jtf_proveedornombre2"); // NOI18N

                            jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
                            jLabel3.setName("jLabel3"); // NOI18N

                            jtf_idactual.setEditable(false);
                            jtf_idactual.setText(resourceMap.getString("jtf_idactual.text")); // NOI18N
                            jtf_idactual.setName("jtf_idactual"); // NOI18N

                            javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
                            jPanel8.setLayout(jPanel8Layout);
                            jPanel8Layout.setHorizontalGroup(
                                jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel8Layout.createSequentialGroup()
                                    .addComponent(jtf_idactual, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 158, Short.MAX_VALUE)
                                    .addComponent(jLabel3)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jtf_proveedornombre2, javax.swing.GroupLayout.PREFERRED_SIZE, 383, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(123, 123, 123))
                                .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 773, Short.MAX_VALUE)
                            );
                            jPanel8Layout.setVerticalGroup(
                                jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel8Layout.createSequentialGroup()
                                    .addContainerGap()
                                    .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(jtf_proveedornombre2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jLabel3)
                                        .addComponent(jtf_idactual, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 353, Short.MAX_VALUE)
                                    .addContainerGap())
                            );

                            jTabbedPane2.addTab(resourceMap.getString("jPanel8.TabConstraints.tabTitle"), jPanel8); // NOI18N

                            jPanel9.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel9.border.title"))); // NOI18N
                            jPanel9.setName("jPanel9"); // NOI18N

                            jScrollPane6.setName("jScrollPane6"); // NOI18N

                            jt_articulosestadisticas.setModel(this.jtable_modelo_articyestadis);
                            jt_articulosestadisticas.setName("jt_articulosestadisticas"); // NOI18N
                            jt_articulosestadisticas.setRowHeight(22);
                            jt_articulosestadisticas.addMouseListener(new java.awt.event.MouseAdapter() {
                                public void mouseClicked(java.awt.event.MouseEvent evt) {
                                    jt_articulosestadisticasMouseClicked(evt);
                                    if(evt.getClickCount() >= 1)
                                    {
                                        dioclickhisdetesta(evt);
                                        //System.out.println(" double click" );
                                    }
                                    if(evt.getClickCount() >= 2)
                                    {
                                        dioclickhisdet(evt);
                                        //System.out.println(" double click" );
                                    }
                                }
                            });
                            jt_articulosestadisticas.addMouseListener(new java.awt.event.MouseAdapter() {
                                public void mouseClicked(java.awt.event.MouseEvent evt) {
                                    jt_articulosestadisticasMouseClicked(evt);
                                }
                            });
                            jScrollPane6.setViewportView(jt_articulosestadisticas);

                            jtf_proveedornombre1.setEditable(false);
                            jtf_proveedornombre1.setFont(resourceMap.getFont("jtf_proveedornombre1.font")); // NOI18N
                            jtf_proveedornombre1.setName("jtf_proveedornombre1"); // NOI18N

                            jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
                            jLabel2.setName("jLabel2"); // NOI18N

                            jPanel24.setName("jPanel24"); // NOI18N

                            jScrollPane16.setName("jScrollPane16"); // NOI18N

                            System.out.println("esta inicializando estadistica");
                            jtbl_estadisticasarticulo1.setFont(resourceMap.getFont("jtbl_estadisticasarticulo1.font")); // NOI18N
                            jtbl_estadisticasarticulo1.setModel(this.jtable_modelo_estadisticas);
                            jtbl_estadisticasarticulo1.setName("jtbl_estadisticasarticulo1"); // NOI18N
                            jtbl_estadisticasarticulo1.setRowHeight(26);
                            jScrollPane16.setViewportView(jtbl_estadisticasarticulo1);

                            javax.swing.GroupLayout jPanel24Layout = new javax.swing.GroupLayout(jPanel24);
                            jPanel24.setLayout(jPanel24Layout);
                            jPanel24Layout.setHorizontalGroup(
                                jPanel24Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jScrollPane16, javax.swing.GroupLayout.DEFAULT_SIZE, 761, Short.MAX_VALUE)
                            );
                            jPanel24Layout.setVerticalGroup(
                                jPanel24Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel24Layout.createSequentialGroup()
                                    .addComponent(jScrollPane16, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            );

                            jtf_proveedornombre3.setFont(resourceMap.getFont("jtf_proveedornombre3.font")); // NOI18N
                            jtf_proveedornombre3.setName("jtf_proveedornombre3"); // NOI18N

                            jTextField1.setEditable(false);
                            jTextField1.setFont(resourceMap.getFont("jTextField1.font")); // NOI18N
                            jTextField1.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
                            jTextField1.setText(resourceMap.getString("jTextField1.text")); // NOI18N
                            jTextField1.setName("jTextField1"); // NOI18N

                            jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
                            jLabel5.setName("jLabel5"); // NOI18N

                            jTextField2.setEditable(false);
                            jTextField2.setFont(resourceMap.getFont("jTextField2.font")); // NOI18N
                            jTextField2.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
                            jTextField2.setName("jTextField2"); // NOI18N

                            jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
                            jLabel6.setName("jLabel6"); // NOI18N

                            javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
                            jPanel9.setLayout(jPanel9Layout);
                            jPanel9Layout.setHorizontalGroup(
                                jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel9Layout.createSequentialGroup()
                                    .addGap(23, 23, 23)
                                    .addComponent(jLabel2)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jtf_proveedornombre1, javax.swing.GroupLayout.PREFERRED_SIZE, 275, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jLabel5)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 16, Short.MAX_VALUE)
                                    .addComponent(jLabel6)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 761, Short.MAX_VALUE)
                                .addGroup(jPanel9Layout.createSequentialGroup()
                                    .addComponent(jtf_proveedornombre3, javax.swing.GroupLayout.PREFERRED_SIZE, 383, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addContainerGap())
                                .addComponent(jPanel24, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            );
                            jPanel9Layout.setVerticalGroup(
                                jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel9Layout.createSequentialGroup()
                                    .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(jtf_proveedornombre1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jLabel2)
                                        .addComponent(jLabel5)
                                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jLabel6))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 216, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jtf_proveedornombre3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jPanel24, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addContainerGap())
                            );

                            jTabbedPane2.addTab(resourceMap.getString("jPanel9.TabConstraints.tabTitle"), jPanel9); // NOI18N

                            javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
                            jPanel7.setLayout(jPanel7Layout);
                            jPanel7Layout.setHorizontalGroup(
                                jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel7Layout.createSequentialGroup()
                                    .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 245, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jTabbedPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 782, Short.MAX_VALUE))
                            );
                            jPanel7Layout.setVerticalGroup(
                                jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel7Layout.createSequentialGroup()
                                    .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                        .addComponent(jTabbedPane2, javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
                                        .addComponent(jScrollPane5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE))
                                    .addGap(98, 98, 98))
                            );

                            jTabbedPane1.addTab(resourceMap.getString("jPanel7.TabConstraints.tabTitle"), jPanel7); // NOI18N

                            jMenuBar1.setName("jMenuBar1"); // NOI18N

                            jMenu1.setText(resourceMap.getString("jMenu1.text")); // NOI18N
                            jMenu1.setName("jMenu1"); // NOI18N

                            jmni_salir.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.ALT_MASK));
                            jmni_salir.setIcon(resourceMap.getIcon("jmni_salir.icon")); // NOI18N
                            jmni_salir.setText(resourceMap.getString("jmni_salir.text")); // NOI18N
                            jmni_salir.setName("jmni_salir"); // NOI18N
                            jmni_salir.addActionListener(new java.awt.event.ActionListener() {
                                public void actionPerformed(java.awt.event.ActionEvent evt) {
                                    jmni_salirActionPerformed(evt);
                                }
                            });
                            jMenu1.add(jmni_salir);

                            jMenuBar1.add(jMenu1);

                            jMenu2.setText(resourceMap.getString("jMenu2.text")); // NOI18N
                            jMenu2.setName("jMenu2"); // NOI18N

                            jmni_escape.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0));
                            jmni_escape.setText(resourceMap.getString("jmni_escape.text")); // NOI18N
                            jmni_escape.setName("jmni_escape"); // NOI18N
                            jmni_escape.addActionListener(new java.awt.event.ActionListener() {
                                public void actionPerformed(java.awt.event.ActionEvent evt) {
                                    jmni_escapeActionPerformed(evt);
                                }
                            });
                            jMenu2.add(jmni_escape);

                            jMenuItem1.setText(resourceMap.getString("jMenuItem1.text")); // NOI18N
                            jMenuItem1.setName("jMenuItem1"); // NOI18N
                            jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
                                public void actionPerformed(java.awt.event.ActionEvent evt) {
                                    jMenuItem1ActionPerformed(evt);
                                }
                            });
                            jMenu2.add(jMenuItem1);

                            jMenuItem2.setText(resourceMap.getString("jMenuItem2.text")); // NOI18N
                            jMenuItem2.setName("jMenuItem2"); // NOI18N
                            jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
                                public void actionPerformed(java.awt.event.ActionEvent evt) {
                                    jMenuItem2ActionPerformed(evt);
                                }
                            });
                            jMenu2.add(jMenuItem2);

                            jMenuBar1.add(jMenu2);

                            setJMenuBar(jMenuBar1);

                            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
                            getContentPane().setLayout(layout);
                            layout.setHorizontalGroup(
                                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 1038, Short.MAX_VALUE)
                            );
                            layout.setVerticalGroup(
                                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 473, javax.swing.GroupLayout.PREFERRED_SIZE))
                            );

                            pack();
                        }// </editor-fold>//GEN-END:initComponents

    private void jmni_salirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmni_salirActionPerformed
        // TODO add your handling code here:
         if(JOptionPane.showConfirmDialog(null, "Desea Salir?")==0)
                {
                    this.dispose();
                }
}//GEN-LAST:event_jmni_salirActionPerformed

    private void jbtn_salirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_salirActionPerformed
        // TODO add your handling code here:
        //        x.cierraConexion();   // TODO add your handling code here:
        this.dispose();
}//GEN-LAST:event_jbtn_salirActionPerformed

    private void jmni_escapeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmni_escapeActionPerformed
        // TODO add your handling code here:
        this.jmni_salirActionPerformed(evt);
    }//GEN-LAST:event_jmni_escapeActionPerformed

    private void jbtn_buscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_buscarActionPerformed
        // TODO add your handling code here:
        // this.jtf_busqueda.getText();
        if(JOptionPane.showConfirmDialog(null, "Estan Correctos sus Datos?")==0) {
           String arreglo_cla[]=this.jcbx_clasificacion.getSelectedItem().toString().split(":");
           this.cargar_datosarticulosexisyacum(opcioncons, arreglo_cla[0],opvs);
        }

    }//GEN-LAST:event_jbtn_buscarActionPerformed

    private void jTabbedPane2StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jTabbedPane2StateChanged
        // TODO add your handling code here:
        indexactual=this.jTabbedPane2.getSelectedIndex();
        if(band>0)
        {
           if((indexactual==1)&&(yacargue1==0))
                {
                    yacargue1=1;
                    this.cargar_datos_periodo(3, "0",this.jtf_idactual.getText());

                    this.centrar_datos();
                }
        if((indexactual==0)&&(yacargue0==0))
                {
                    yacargue0=1;
                      this. cargar_datosventaxmes(this.jtf_idactual.getText());
                      this. cargar_datoscomprasxmes(this.jtf_idactual.getText());

                      this.centrar_datos();
                }
        if((indexactual==2)&&(yacargue2==0))
                {
                    if(this.jtf_proveedornombre1.getText().toString().length()>0)
                        {
                            yacargue2=1;
                            this.cargar_datosarticulosexisyacumdet(1,"0",this.jtf_idactual.getText());
                        }
                    else
                        {
                        JOptionPane.showMessageDialog(null," Elija Un Proveedor!!", "Sistema Integral(requisicion Articulos) : Error",1);
                        }
                }
        }
    }//GEN-LAST:event_jTabbedPane2StateChanged

    private void jt_articulosestadisticasMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jt_articulosestadisticasMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_jt_articulosestadisticasMouseClicked

    private void jrbn_repguarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jrbn_repguarActionPerformed
        // TODO add your handling code here:
             opcioncons=Integer.parseInt(evt.getActionCommand().toString());
    }//GEN-LAST:event_jrbn_repguarActionPerformed

    private void jrbn_repcontruyeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jrbn_repcontruyeActionPerformed
        // TODO add your handling code here:
           opcioncons=Integer.parseInt(evt.getActionCommand().toString());
    }//GEN-LAST:event_jrbn_repcontruyeActionPerformed

    private void jrbn_vscomprasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jrbn_vscomprasActionPerformed
        // TODO add your handling code here:
            opvs="1";
}//GEN-LAST:event_jrbn_vscomprasActionPerformed

    private void jrbn_vsexistenciaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jrbn_vsexistenciaActionPerformed
        // TODO add your handling code here:
           opvs="2";
}//GEN-LAST:event_jrbn_vsexistenciaActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        // TODO add your handling code here:
              try {
            // TODO add your handling code here:
            this.jtb_provee_comvsventas.print();
        } catch (PrinterException ex) {
            Logger.getLogger(com_distri_compras_detalle.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        // TODO add your handling code here:
                    try {
            // TODO add your handling code here:
            this.jt_articulosestadisticas.print();
        } catch (PrinterException ex) {
            Logger.getLogger(com_distri_compras_detalle.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jMenuItem2ActionPerformed
       private void jtb_provee_comvsventas3MouseClicked(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:
    }
   
      private void dioclick(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:
        int fila = jtb_provee_comvsventas.getSelectedRow();
        String valor[] = jtb_provee_comvsventas.getValueAt(fila, 1).toString().split(":");
        com_distri_compras_proveedores_edita fcdcpe=new com_distri_compras_proveedores_edita(valor[0]);
        fcdcpe.pack();
        fcdcpe.setVisible(true);

    }

       private void dioclickp(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:
        int fila = jtb_provee_comvsventas.getSelectedRow();
        String valor[] = jtb_provee_comvsventas.getValueAt(fila, 1).toString().split(":");
        this.jtf_idactual.setText(valor[2]);
        this.jtb_provee_comvsventas3.changeSelection(fila, 0, true, false);
    System.out.println(" seleccionando" );
    }


private void dioclickhis(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:

       // int fila = jtb_provee_comvsventas1.getSelectedRow();
       // String valor[] = jtable_modelo_det.getValueAt(fila, 0).toString().split(":");
       // this. cargar_datosventaxmes(valor[2]);
       // this. cargar_datoscomprasxmes(valor[2]);
       // this.jtf_proveedornombre.setText(valor[1]);
       // this.centrar_datos();
    }
private void dioclickhisdet(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:

     System.out.println("dio doble  click");
         int fila = jt_articulosestadisticas.getSelectedRow();
         String valor[] = jtable_modelo_articyestadis.getValueAt(fila, 1).toString().split(":");
if(JOptionPane.showConfirmDialog(null, "<html>Deseas ver Detalle de Articulo</html>")==0)
            {
            //JFrame mainFrame = Sie_invdisApp.getApplication().getMainFrame();
            articulos_sie_editar fase=new articulos_sie_editar(valor[0]);
            fase.pack();
            fase.setVisible(true);
        }
    }
private void dioclickhisdetesta(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:

     System.out.println("dio doble  click");
         int fila = jt_articulosestadisticas.getSelectedRow();
         if(JOptionPane.showConfirmDialog(null, "<html>Deseas ver Estadistica de Articulo</html>")==0)
            {
                String valor[] = jtable_modelo_articyestadis.getValueAt(fila, 1).toString().split(":");
                this.jtf_proveedornombre3.setText(valor[1]+":"+ jtable_modelo_articyestadis.getValueAt(fila, 2).toString());
                this.carga_articulo_estadisticas("0", valor[0]);
            }
    }

private void dioclickper(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:

        int fila = jtb_provee_comvsventas3.getSelectedRow();
        String valor[] = jtable_modelo_periodo.getValueAt(fila, 0).toString().split(":");
   if(JOptionPane.showConfirmDialog(null, "<html>Deseas ver Detalle proveedor:<br><h3>"+valor[2]+"?</h3></html>")==0)
                {

                   this.jtf_idactual.setText(valor[1]);
                    this.jtf_proveedornombre2.setText(valor[2]);
                    this.jtf_proveedornombre1.setText(valor[2]);
                    this.jtf_proveedornombre.setText(valor[2]);

                    this.jTextField1.setText(jtable_modelo.getValueAt(fila, 3).toString());
                    this.jTextField2.setText(jtable_modelo.getValueAt(fila, 6).toString());

                    yacargue0=0;
                    yacargue1=0;
                    yacargue2=0;

                    if((indexactual==1)&&(yacargue1==0))
                        {
                            yacargue1=1;
                            this.cargar_datos_periodo(3, "0",this.jtf_idactual.getText());

                            this.centrar_datos();
                        }
                    if((indexactual==0)&&(yacargue0==0))
                            {
                                yacargue0=1;
                                this. cargar_datosventaxmes(this.jtf_idactual.getText());
                                this. cargar_datoscomprasxmes(this.jtf_idactual.getText());

                              this.centrar_datos();
                        }
                if((indexactual==2)&&(yacargue2==0))
                        {
                            yacargue2=1;
                            this.cargar_datosarticulosexisyacumdet(1,"0",this.jtf_idactual.getText());
                        }
            }
    }

private void jtb_provee_comvsventasMouseClicked(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:
    }

  
    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new com_distri_provee_comp_vs_ven().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel24;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane16;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTabbedPane jTabbedPane2;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JButton jbtn_buscar;
    private javax.swing.JButton jbtn_salir;
    private javax.swing.JComboBox jcbx_clasificacion;
    private javax.swing.JMenuItem jmni_escape;
    private javax.swing.JMenuItem jmni_salir;
    private javax.swing.JRadioButton jrbn_repcontruye;
    private javax.swing.JRadioButton jrbn_repguar;
    private javax.swing.JRadioButton jrbn_vscompras;
    private javax.swing.JRadioButton jrbn_vsexistencia;
    private javax.swing.JTable jt_articulosestadisticas;
    private javax.swing.JTable jt_vengenxmes;
    private javax.swing.JTable jt_vengenxmes1;
    private javax.swing.JTable jtb_provee_comvsventas;
    private javax.swing.JTable jtb_provee_comvsventas3;
    private javax.swing.JTable jtbl_estadisticasarticulo1;
    private javax.swing.JTextField jtf_idactual;
    private javax.swing.JTextField jtf_proveedornombre;
    private javax.swing.JTextField jtf_proveedornombre1;
    private javax.swing.JTextField jtf_proveedornombre2;
    private javax.swing.JTextField jtf_proveedornombre3;
    // End of variables declaration//GEN-END:variables

}
